#!/usr/bin/perl

##########################################################################
##                                                                       #
## This file is part of the DogosFrame distribution.  For full copyright #
## information, see COPYRIGHT and COPYING.LESSER.                        #
##                                                                       #
## Author:           sqbang                                              #
## Email:            sqbang@ustc.edu                                     #
## Date:             2013.12.11                                          #
## Acknowledegments: This file is a copy from SAMRAI projection          #
##                   with slight modification.                           #
## Description:      Code-generating script in inputdb package.          #
##                                                                       #
##########################################################################

while(<>) {
    s/^#line.*//;
    s/.*Revision:.*//;
    s/.*Date:.*//;
    
    # substitution to replace [yynerrs,yychar,yylval] with DOGOS_[yynerrs,yychar,yylval]
    s/yynerrs/DOGOS_yynerrs/g;
    s/yychar/DOGOS_yychar/g;
    s/yylval/DOGOS_yylval/g;
    
    # These fixup some warning messages coming from insure++

    s/^# define YYDPRINTF\(Args\)$/# define YYDPRINTF(Args) do {} while (0)/;
    s/^# define YYDSYMPRINT\(Args\)$/# define YYDSYMPRINT(Args) do {} while (0)/;
    s/^# define YYDSYMPRINTF\(Title, Token, Value, Location\)$/# define YYDSYMPRINTF(Title, Token, Value, Location) do {} while (0)/;
    s/^# define YY_STACK_PRINT\(Bottom, Top\)$/# define YY_STACK_PRINT(Bottom, Top) do {} while (0)/;
    s/^# define YY_REDUCE_PRINT\(Rule\)$/# define YY_REDUCE_PRINT(Rule) do {} while (0)/;

    s/(\s+);}/$1\}/;

    # a more silent null use
    s/\(void\) yyvaluep;/if(0) {char *temp = (char *)&yyvaluep; temp++;}/;

    s/\/\* empty \*\/;//;

    print $_;
}

